flutter setup
2022-12-02 · 3 min read
prereqs #
- (Optional, android) android cli setup
- (Optional, iOS, macOS-only) ios setup
- (macOS, apple silicon)
sudo softwareupdate --install-rosetta --agree-to-license
install flutter #
https://docs.flutter.dev/get-started/install
$ git clone --branch="stable" \
https://github.com/flutter/flutter.git \
~/.local/flutter
# ensure .bashrc contains these lines:
#
# ```
# # Flutter
# FLUTTER_HOME=$HOME/.local/flutter
# export PATH=$PATH:$FLUTTER_HOME/bin
# ```
setup flutter #
# disable their pesky telemetry : )
$ flutter config --suppress-analytics --no-analytics
$ dart --disable-analytics
# run the flutter sanity checker
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel unknown, 3.3.9, on Pop!_OS 22.04 LTS 6.0.6-76060006-generic, locale en_US.UTF-8)
! Flutter version 3.3.9 on channel unknown at /home/phlip9/.local/flutter
! Upstream repository unknown
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✗] Linux toolchain - develop for Linux desktop
✗ GTK 3.0 development libraries are required for Linux development.
They are likely available from your distribution (e.g.: apt install libgtk-3-dev)
[!] Android Studio (not installed)
[✓] Connected device (1 available)
[✓] HTTP Host Availability
! Doctor found issues in 4 categories.
Once you've setup your devices (e.g. android cli setup > (optional) setup wireless debugging on device), verify that flutter actually picks up the mobile device.
On my linux desktop:
$ flutter devices
Pixel 5a (mobile) • android-arm64 • Android 13 (API 33)
Linux (desktop) • linux-x64 • Pop!_OS 22.04 LTS
On my M1 MBP:
$ flutter devices
3 connected devices:
Pixel 5a (mobile) • android-arm64 • Android 13 (API 33)
iPhone 14 Pro (mobile) • ios • iOS-16-2 (simulator)
macOS (desktop) • macos • darwin-arm64 • macOS 13.1 darwin-arm
(linux pop_OS!) install libstdc++-12-dev
#
If you want to run linux desktop apps:
$ sudo apt install libstdc++-12-dev
test sample app #
$ flutter create --platforms android my_app
$ cd my_app
# this should build, install, and launch the sample app on your phone
$ flutter run -d pixel
$ flutter run -d iphone
editor (nvim) #
For all the nvim
chads out there using coc.nvim
, just do:
:CocInstall coc-flutter
Probably set "dart.showTodos": false
in your coc-settings.json
.
Maybe peep these keybinds too:
nnoremap <silent> <leader>fd :CocCommand flutter.devices<CR>
nnoremap <silent> <leader>fr :CocCommand flutter.run<CR>
nnoremap <silent> <leader>ft :CocCommand flutter.dev.hotRestart<CR>
nnoremap <silent> <leader>fs :CocCommand flutter.dev.quit<CR>
nnoremap <silent> <leader>fl :CocCommand flutter.dev.openDevLog<CR>
Now instead of running flutter run
to build the app, just use <leader>fr
or :CocCommand flutter.run
. This will setup a live-reload session; whenever you save a .dart
file, the app UI will live reload with any UI-related changes. State changes still need a "hot restart" (<leader>ft
). Pretty sick though.